#include <iostream>
#include<vector>
using namespace std;

int main() {
    int size;
    while (cin >> size) {
        vector<int> v;
        for (int i = 0; i < size; i++) {
            int a;
            cin >> a;
            v.push_back(a);
        }
        vector<int> price(size + 1);
        for (int x = 2; x < price.size(); x++) {
            price[x] = price[x - 1] + v[x - 1] > price[x - 2] + v[x - 2] ? price[x - 2] +
                v[x - 2] : price[x - 1] + v[x - 1];
        }
        cout << price[size];
    }
    return 0;
}
